package xyz.scootaloo.oj.leetcode

import org.junit.Test
import xyz.scootaloo.common.TestDsl

/**
 * @author flutterdash@qq.com
 * @since 2021/7/4 14:54
 */
class P283 : TestDsl {

    private fun moveZeroes(nums: IntArray) {
        var zeroCount = 0
        for (i in nums.indices) {
            if (nums[i] == 0) {
                zeroCount++
            } else {
                if (zeroCount > 0) {
                    nums[i - zeroCount] = nums[i]
                }
            }
        }

        val end = nums.size
        val begin = end - zeroCount
        for (i in begin until end)
            nums[i] = 0
    }

    @Test
    fun test0() {
        val input1 = intArrayOf(0, 1, 0, 3, 12)
        moveZeroes(input1)
        input1.log()
//        moveZeroes(intArrayOf(0, 1, 0, 3, 12)).print()
    }

}
